import oss2
import os, shutil
import schedule
import time

auth = oss2.Auth('LTAI4GA4G2KFgjUXcDapGfvc', 'CUizwQVRaJKMd2JqhxbsAmgSk7qvFN')
bucket = oss2.Bucket(auth, 'http://oss-cn-beijing.aliyuncs.com', 'recordata-wzy')

def tick_data_upload(tick_data_foloder):
    for tick_data in os.listdir(tick_data_foloder):
        tick_data_file = tick_data_foloder + '/' + tick_data
        bucket.put_object_from_file('tick_data_{}/{}'.format(time.strftime("%Y%m%d",time.localtime()), tick_data), tick_data_file)

# def del_create_folder(floder_name):
#     shutil.rmtree(floder_name)
#     os.mkdir(floder_name)

schedule.every().saturday.at("12:00").do(tick_data_upload, '/home/zhangdf/ctp/tick_data')
# schedule.every().thursday.at("18:18").do(del_create_folder, '../tick_data')
while True:
    schedule.run_pending()
    time.sleep(0.5)